'use strict';

const mountRouterMap = require("./utils/mountRouterMap");

const Home = {
	controllerMethodPath: "/home",
	mountPath: "/",
	mount: {
		get: [
			"import_booklet", ["index", ""], "user", "user_booklet"
		]
	}
}

const BackUser = {
	controllerMethodPath: "/back/user",
	mountPath: "/back_api/v1.0/users",
	mount: {
		get: [
		]
	}
}

const User = {
	controllerMethodPath: "/front/user",
	mountPath: "/api/v1.0/users",
	mount: {
		post: ["vertify"],
		get: [
			['booklets', '/:user_id/booklets']
		]
	}
}

const Section = {
	controllerMethodPath: "/front/section",
	mountPath: "/api/v1.0/sections",
	mount: {
		post: ['import_sections'],
	}
}

const Booklet = {
	controllerMethodPath: "/front/booklet",
	mountPath: "/api/v1.0/booklets",
	mount: {
		get: [
			["getBookletSections", "/:booklet_id/sections"]
		],
	}
}

const BackUserBooklet = {
	controllerMethodPath: "/back/userBooklet",
	mountPath: "/back_api/v1.0/user_booklets",
	mount: {
		delete: [
			["softDestroy", "/:user_id"]
		],
	}
}

const routerMap = {
	Home,
	User,
	Section,
	Booklet,
	BackUser,
	BackUserBooklet
}


module.exports = app => {
  const { router, controller } = app;
	mountRouterMap(router, controller, routerMap);
	router.resources('users', '/api/v1.0/users', controller.front.user)
	router.resources('back_users', '/back_api/v1.0/users', controller.back.user)
	router.resources('back_user_booklets', '/back_api/v1.0/user_booklets', controller.back.userBooklet)
	router.resources('sections', '/api/v1.0/sections', controller.front.section)
	router.resources('booklets', '/api/v1.0/booklets', controller.front.booklet)
};
